<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl">
    <link rel="stylesheet" href="/js/plugins/treeview/bootstrap-treeview.min.css" type="text/css">
    <script type="text/javascript" src="/js/plugins/treeview/bootstrap-treeview.min.js"></script>
    <script type="text/javascript" src="/js/plugins/ckeditor/ckeditor.js"></script>
    <script>
        $(function () {
            $('.deleteBtn').click(function () {
                var travelId = $(this).data('id');
                $.messager.confirm("温馨提示","您确定要删除吗？",function () {
                    $.get('/travel/deleteTravelId.do',{travelId:travelId},function (data) {
                        if(data.success){
                            location.reload();
                        }
                    })
                });
            });
            $('.addBtn').click(function () {
                var id = $('#status').val();
                if (id != -1){
                    var text = $("#searchForm option:selected").text();
                    $('#strategyTitle').val(text);
                    $('#strategyId').val(id);
                }
                $('#inputModal').modal('show');
            });
            $('.inputSubmit').click(function () {
                $('#inputForm').submit();
            });
        });
    </script>
</head>
<body>
<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#assign currentMenu = "listTravels" />
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">大家都在看</h1>
                </div>
            </div>
            <form class="form-inline" id="searchForm" action="/travel/listTravels.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label >攻略搜索:</label>
                    <select class="form-control" id="status" name="strategyId">
                        <option value="-1">全部</option>
                        <#list strategies as s>
                            <option value="${s.id}">${s.title}</option>
                        </#list>
                    </select>
                    <script>
                        $("#status option[value='${qo.strategyId}']").prop("selected", true);
                    </script>
                </div>
                <button id="btn_query" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <a class="btn btn-success addBtn">
                    <span href="javascript:" class="glyphicon glyphicon-plus"></span> 添加关联
                </a>
            </form>
            <div class="row">
                <table class="table table-striped table-hover">
                        <#list pageInfo.list as entitry>
                        <tr>
                            <td>${entitry.title}</td>
                            <td>
                                <a target="_blank"  class="btn btn-info btn-xs inputBtn"
                                   href="/travel/releaseList.do?travelId=${entitry.id}">
                                    <span class="glyphicon glyphicon-pencil"></span>查看游记文章
                                </a>
                            </td>
                            <td>
                                <a data-id="${entitry.id}"
                                        class="btn btn-info btn-xs deleteBtn" href="javascript:">
                                    <span class="glyphicon glyphicon-pencil"></span>删除
                                </a>
                            </td>
                        </tr>
                        </#list>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/travel/save.do" method="post"
                      id="inputForm">
                    <input type="hidden" name="strategyId" id="strategyId">
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">所属攻略：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" id="strategyTitle" readonly />
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">关联游记：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="travelId">
                                <#list travels as t>
                                    <option value="${t.id}">${t.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary inputSubmit">保存</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>